import { UserModel } from '@/api/system/user/UserModel'
import { reactive } from 'vue'

export default function useBaseModel() {
    // 表单绑定的数据
    const addModel = reactive<UserModel>({
        type: '', //判断新增还是编辑
        id: '',
        username: '',
        password: '',
        nickname: '',
        status: '1',
        mobile: '',
        email: ''
    })

    //表单验证规则
    const rules = reactive({
        username: [
            {
                required: true,
                message: '请填写用户名称',
                trigger: 'blur'
            },
            { min: 2, max: 50, message: '长度为2-50个字符', trigger: 'blur' }
        ],
        nickname: [
            {
                required: true,
                message: '请填写昵称',
                trigger: 'blur'
            },
            { min: 2, max: 50, message: '长度为2-50个字符', trigger: 'blur' }
        ]
    })

    return {
        addModel,
        rules
    }
}
